package alg1;

import java.util.ArrayList;
import java.util.Scanner;

/**
 * @author 24岁没牵过女人的手
 * 日期：2023/8/17 15:36
 * 文件描述：
 */
public class ALGO {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.nextLine());
        while(N --> 0){
            String str = sc.nextLine();
            StringBuilder s = new StringBuilder(str);
            for(int i = 0; i + 2 < s.length(); ++i){
                char a = s.charAt(i), b = s.charAt(i + 1), c = s.charAt(i + 2);
                if(a == b && b == c) s.deleteCharAt(i--);
            }
            for(int i = 0; i + 3 < s.length(); ++i){
                char a = s.charAt(i), b = s.charAt(i + 1), c = s.charAt(i + 2), d = s.charAt(i + 3);
                if(a == b && c == d) s.deleteCharAt(i + 2);
            }
            System.out.println(s);
        }    }
}
